﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AutoMapper;
using NpCrm.DataAccess.Core;
using NpCrm.Domain;
using NpCrm.WebClient.ViewModels.Contact;

namespace NpCrm.WebClient.Controllers
{
    public class ContactController : Controller
    {

        private readonly IContactRepository _repository;

        public ContactController(IContactRepository repository)
        {
            _repository = repository;
        }

        public ActionResult Index()
        {
            var contacts = _repository.All();
            var custList = Mapper.Map<IEnumerable<Contact>, IEnumerable<ContactIndexViewModel>> (contacts);
            return View(custList);
        }

    }
}
